package com.ycsj.goldmedalnewconcept.activity;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.Platform.ShareParams;
import cn.sharesdk.onekeyshare.OnekeyShare;
import cn.sharesdk.onekeyshare.ShareContentCustomizeCallback;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.tencent.qq.QQ;

import com.flyco.animation.BaseAnimatorSet;
import com.flyco.dialog.listener.OnBtnLeftClickL;
import com.flyco.dialog.listener.OnBtnRightClickL;
import com.flyco.dialog.widget.NormalDialog;
import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.mob.MobSDK;
import com.readystatesoftware.systembartint.SystemBarTintManager;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.picasso.Picasso;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.bean.DetailList;
import com.ycsj.goldmedalnewconcept.bean.NewTestResp;
import com.ycsj.goldmedalnewconcept.bean.QuestionInfo;
import com.ycsj.goldmedalnewconcept.bean.QuestionTime;
import com.ycsj.goldmedalnewconcept.bean.timeresq;
import com.ycsj.goldmedalnewconcept.constant.ConfigConstant;
import com.ycsj.goldmedalnewconcept.constant.NetConstant;
import com.ycsj.goldmedalnewconcept.utils.SPUtil;
import com.ycsj.goldmedalnewconcept.utils.SPUtils;

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@SuppressLint({ "SetJavaScriptEnabled", "HandlerLeak", "NewApi" })
public class NewTestThirdActivity extends BaseJpStarActivity implements
		OnClickListener {

	private TextView tv_html_title;
	private TextView tv_word_back;
	private TextView tv_pager;
	private TextView tv_shoucang;
	private TextView tv_player;
	private TextView tv_player_img; // 喇叭图标
	private TextView tv_score;
	private TextView tv_text;
	private TextView tv_word1;
	private TextView tv_word2;
	private ImageView iv_type1_img1;
	private ImageView iv_type1_img2;
	private ImageView iv_type1_img3;
	private ImageView iv_type1_img4;
	private ImageView iv_type1_tf1;
	private ImageView iv_type1_tf2;
	private ImageView iv_type1_tf3;
	private ImageView iv_type1_tf4;
	private LinearLayout ll_type1;
	private LinearLayout ll_type2;
	private LinearLayout ll_type3;
	private LinearLayout ll_type4;
	private LinearLayout ll_type5;
	private LinearLayout ll_type6;
	private ProgressBar progress_bar;
	private ImageView iv_type3_img;
	private TextView tv_showword;
	private TextView tv_del;
	private TextView tv_check;
	private TextView tv_true_bt;
	private TextView tv_false_bt;
	private ImageView iv_type4_img;
	private TextView tv_board;
	private TextView tv_type5_del;
	private TextView tv_choice1;
	private TextView tv_choice2;
	private TextView tv_choice3;
	private ImageView iv_type6_img;
	
	
	private ImageView iv_share;
	private String question_count; 	// 总数
	private String question_answer; // 答案
	private String question_type; 	// 题型
	private String audio_url = ""; 		// 题目音频
	private String lESSON_ID;
	private String Score = "";
	private String Time = "";
	private String answer1;
	private String answer2;
	private String answer3;
	private String answer4;
	private String word1 = "";
	private String word2 = "";
	private String letter = "";    	//输入框内容
	private String letter1 = "";    	//输入框内容
	private MediaPlayer mediaPlayer;
	private String account;
	private String array = "";
	private int question_num = 0; 	// 当前题目集合角标
	private int score = 0; 			// 成绩
	private int p; 					// 点击位置
	private int Click = 1; 			// 点击次数
	private int ClickType1; 		// 点击类型
	private int ClickType2; 		// 点击类型
	private int alltrue = 0; 		// 题型2是否得分
	private List<QuestionInfo> list;
	private List<DetailList> detaillist;
	private List<Integer> dismissedlist;
	private List<String> Letterlist;
	private List<String> typefivelist;
	private List<QuestionTime> timelist;
	private MyHandler handler;
	private PopupWindow mPopWindow1;
	private PopupWindow mPopWindow2;
	private PopupWindow mPopWindow3;
	private GridView gv_match;
	private GridView gv_letter;
	private GridView gv_type5;
	private View rootview;
	private MatchAdapter mAdapter;
	private LetterAdapter mAdapter1;
	private TypefiveAdapter mAdapter5;
	private Message message4;
	private Date curDate;
	private Date endDate;
	private long diff;
	private int totalTime = 0;//总时间
	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Boolean isfavor=false;
	private int type4 = 0;  
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().requestFeature(Window.FEATURE_PROGRESS);
		setContentView(R.layout.activity_newfuxi);

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			setTranslucentStatus(true);
		}
		SystemBarTintManager tintManager = new SystemBarTintManager(this);
		tintManager.setStatusBarTintEnabled(true);
		tintManager.setStatusBarTintResource(R.color.base_color);

		account = SPUtils.getString(this, ConfigConstant.USERNAME);

		lESSON_ID = getIntent().getStringExtra("LESSON_ID");
		lESSON_NAME = getIntent().getStringExtra("LESSON_NAME");
		Log.e("test", lESSON_NAME);
		Log.e("test", lESSON_ID + "");
		handler = new MyHandler(this);
		timelist = new ArrayList<QuestionTime>();
		
		initView();
		initListener();
		initData();
		initpop();
//		initRegisterBroadCast();
		tv_html_title.setText(lESSON_NAME);
	}

	
	/**
	 * 注册广播
	 */
	private void initRegisterBroadCast() {
		
		
		IntentFilter filter = new IntentFilter();
        filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
        filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        registerReceiver(new TimingReceiver(), filter);
	}

	
	/**
	 * 断网计时广播接受者
	 * 
	 * @author Administrator
	 *
	 */
	class TimingReceiver extends BroadcastReceiver {
		
		@Override
		public void onReceive(Context context, Intent intent) {
			
			  // 监听网络连接，包括wifi和移动数据的打开和关闭,以及连接上可用的连接都会接到监听
	        if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
	            //获取联网状态的NetworkInfo对象
	            NetworkInfo info = intent
	                    .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
	            if (info != null) {
	                //如果当前的网络连接成功并且网络连接可用
	                if (NetworkInfo.State.CONNECTED == info.getState() && info.isAvailable()) {
	                    if (info.getType() == ConnectivityManager.TYPE_WIFI
	                            || info.getType() == ConnectivityManager.TYPE_MOBILE) {
	                    	
	                    	Log.i("test", "网络重新连接");
	        				
	        				String gradeid = String.valueOf(lESSON_ID).substring(0, 4);
	        				HttpUtils httpUtils2 = new HttpUtils();
	        				httpUtils2.configCurrentHttpCacheExpiry(1000);
	        				httpUtils2.send(HttpMethod.GET,
	        						NetConstant.USERONLINE
	        								+ "InitInterfaceBegin.aspx?msg=1&type=3&account="
	        								+ SPUtils.getString(NewTestThirdActivity.this, "account")
	        								+ "&gradeid=" + gradeid + "&lessonid=" + lESSON_ID,
	        						callBackTime);
	                    }
	                }
	            }
	        }
		}
	}
	
	
	
	@Override
	protected void onStart() {
		curDate = new Date(System.currentTimeMillis());   //开始计时
		super.onStart();
	}
	
	private void initpop() {
		View contentView1 = LayoutInflater.from(this).inflate(
				R.layout.popup_true, null);
		View contentView2 = LayoutInflater.from(this).inflate(
				R.layout.popup_null, null);
		View contentView3 = LayoutInflater.from(this).inflate(
				R.layout.popup_false, null);
		mPopWindow1 = new PopupWindow(contentView1,
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.MATCH_PARENT, true);
		mPopWindow1.setContentView(contentView1);
		mPopWindow1.setBackgroundDrawable(new BitmapDrawable());
		mPopWindow1.setOutsideTouchable(true);

		mPopWindow2 = new PopupWindow(contentView2,
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.MATCH_PARENT, true);
		mPopWindow2.setContentView(contentView2);
		mPopWindow2.setBackgroundDrawable(new BitmapDrawable());
		mPopWindow2.setOutsideTouchable(true);
		rootview = LayoutInflater.from(this).inflate(R.layout.activity_newfuxi,
				null);

		mPopWindow3 = new PopupWindow(contentView3,
				ViewGroup.LayoutParams.MATCH_PARENT,
				ViewGroup.LayoutParams.MATCH_PARENT, true);
		mPopWindow3.setContentView(contentView3);

		mPopWindow3.setBackgroundDrawable(new BitmapDrawable());
		mPopWindow3.setOutsideTouchable(true);
	}

	private void initView() {
		iv_share = (ImageView) findViewById(R.id.iv_share);
		tv_html_title = (TextView) findViewById(R.id.tv_html_title);
		tv_word_back = (TextView) findViewById(R.id.tv_word_back);
		tv_player = (TextView) findViewById(R.id.tv_player);
		tv_pager = (TextView) findViewById(R.id.tv_pager);
		tv_shoucang = (TextView) findViewById(R.id.tv_shoucang);
		tv_score = (TextView) findViewById(R.id.tv_score);
		tv_text = (TextView) findViewById(R.id.tv_text);
		tv_showword = (TextView) findViewById(R.id.tv_showword);
		tv_del = (TextView) findViewById(R.id.tv_del);
		tv_check = (TextView) findViewById(R.id.tv_check);
		tv_player_img = (TextView) findViewById(R.id.tv_player_img);
		tv_true_bt = (TextView) findViewById(R.id.tv_true_bt);
		tv_false_bt = (TextView) findViewById(R.id.tv_false_bt);
		tv_board = (TextView) findViewById(R.id.tv_board);
		tv_type5_del = (TextView) findViewById(R.id.tv_type5_del);
		
		tv_choice1 = (TextView) findViewById(R.id.tv_choice1);
		tv_choice2 = (TextView) findViewById(R.id.tv_choice2);
		tv_choice3 = (TextView) findViewById(R.id.tv_choice3);
		 
		
		iv_type6_img = (ImageView) findViewById(R.id.iv_type6_img);
		
		iv_type1_img1 = (ImageView) findViewById(R.id.iv_type1_img1);
		iv_type1_img2 = (ImageView) findViewById(R.id.iv_type1_img2);
		iv_type1_img3 = (ImageView) findViewById(R.id.iv_type1_img3);
		iv_type1_img4 = (ImageView) findViewById(R.id.iv_type1_img4);
		iv_type3_img = (ImageView) findViewById(R.id.iv_type3_img);
		iv_type4_img = (ImageView) findViewById(R.id.iv_type4_img);
		iv_type1_tf1 = (ImageView) findViewById(R.id.iv_type1_tf1);
		iv_type1_tf2 = (ImageView) findViewById(R.id.iv_type1_tf2);
		iv_type1_tf3 = (ImageView) findViewById(R.id.iv_type1_tf3);
		iv_type1_tf4 = (ImageView) findViewById(R.id.iv_type1_tf4);
		ll_type1 = (LinearLayout) findViewById(R.id.ll_type1);
		ll_type2 = (LinearLayout) findViewById(R.id.ll_type2);
		ll_type3 = (LinearLayout) findViewById(R.id.ll_type3);
		ll_type4 = (LinearLayout) findViewById(R.id.ll_type4);
		ll_type5 = (LinearLayout) findViewById(R.id.ll_type5);
		ll_type6 = (LinearLayout) findViewById(R.id.ll_type6);

		progress_bar = (ProgressBar) findViewById(R.id.progress_bar);
		gv_match = (GridView) findViewById(R.id.gv_match);
		gv_letter = (GridView) findViewById(R.id.gv_letter);
		gv_type5 = (GridView) findViewById(R.id.gv_type5);

	}

	private void initListener() {
		tv_word_back.setOnClickListener(this);
		iv_share.setOnClickListener(this);
		tv_player.setOnClickListener(this);
		iv_type1_img1.setOnClickListener(this);
		iv_type1_img2.setOnClickListener(this);
		iv_type1_img3.setOnClickListener(this);
		iv_type1_img4.setOnClickListener(this);
		tv_shoucang.setOnClickListener(this);
		tv_del.setOnClickListener(this);
		tv_check.setOnClickListener(this);
		tv_true_bt.setOnClickListener(this);
		tv_false_bt.setOnClickListener(this);
		tv_choice1.setOnClickListener(this);
		tv_choice2.setOnClickListener(this);
		tv_choice3.setOnClickListener(this);
		tv_type5_del.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.tv_word_back:
			finish();
			break;
		case R.id.tv_shoucang: // 底部收藏按钮
			if(isfavor){
				Toast.makeText(this, "取消", 0).show();
				isfavor=false;
				tv_shoucang.setBackgroundResource(R.drawable.nav_collect2x);
//				http://192.168.0.198:8080/User_Manage/UserFavor/CancelUserQuestion.aspx?account=12212345678&lessonid=1001001&questionid=1&exam_type=1 
				OkHttpClient mOkHttpClient = new OkHttpClient();
				// mOkHttpClient.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
				int questionid=question_num+1;
				final Request request = new Request.Builder()
						.url(NetConstant.HOST+"User_Manage/UserFavor/CancelUserQuestion.aspx?lessonid="+lESSON_ID+"&account="+SPUtils.getString(this, ConfigConstant.USERNAME)+"&questionid="+questionid+"&exam_type=1")
						.build();
				mOkHttpClient.newCall(request).enqueue(callbackcollect);
				
			}else{
				Toast.makeText(this, "收藏", 0).show();
				isfavor=true;
				tv_shoucang.setBackgroundResource(R.drawable.nav_collect_ed2x);
//				http://192.168.0.198:8080/User_Manage/UserFavor/SaveUserQuestion.aspx?account=12212345678&lessonid=1001001&questionid=1&exam_type=1 
					OkHttpClient mOkHttpClient = new OkHttpClient();
					// mOkHttpClient.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
					//http://m.moregolden.com
					int questionid=question_num+1;
					final Request request = new Request.Builder()
							.url(NetConstant.HOST+"User_Manage/UserFavor/SaveUserQuestion.aspx?lessonid="+lESSON_ID+"&account="+SPUtils.getString(this, ConfigConstant.USERNAME)+"&questionid="+questionid+"&exam_type=1")
							.build();
					mOkHttpClient.newCall(request).enqueue(callbackcollect);
			}
			break;
		case R.id.tv_choice1: 
		case R.id.tv_choice2: 
		case R.id.tv_choice3: 
			switch (v.getId()) {
			case R.id.tv_choice1:
				
				tv_choice1.setClickable(false);
				tv_choice2.setClickable(false);
				tv_choice3.setClickable(false);
				if(question_num < list.size()){
					
				
				if(tv_choice1.getText().toString().equals(list.get(question_num).question_answer)){
					truepopwindow();
					score = score + 4;
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					 
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "0";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "6";
					timelist.add(questiontime);
					totalTime += temptime;
					Log.e("test", totalTime+"");
				}else{
					falsepopwindow();
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					 
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "6";
					timelist.add(questiontime);
					totalTime += temptime;
					Log.e("test", totalTime+"");
				}
				}
				break;
			case R.id.tv_choice2:
				tv_choice1.setClickable(false);
				tv_choice2.setClickable(false);
				tv_choice3.setClickable(false);
				
				if(question_num < list.size()){
				if(tv_choice2.getText().toString().equals(list.get(question_num).question_answer)){
					truepopwindow();
					score = score + 4;
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					 
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "0";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "6";
					timelist.add(questiontime);
					totalTime += temptime;
					Log.e("test", totalTime+"");
				}else{
					falsepopwindow();
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					 
					if(temptime<1){
						temptime = 1;
					}

					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "6";
					timelist.add(questiontime);
					totalTime += temptime;
					Log.e("test", totalTime+"");
				}
				}
				break;
			case R.id.tv_choice3:
				
				tv_choice1.setClickable(false);
				tv_choice2.setClickable(false);
				tv_choice3.setClickable(false);
				
				if(question_num < list.size()){
				if(tv_choice3.getText().toString().equals(list.get(question_num).question_answer)){
					truepopwindow();
					score = score + 4;
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					 
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "0";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "6";
					timelist.add(questiontime);
					totalTime += temptime;
					Log.e("test", totalTime+"");
				}else{
					falsepopwindow();
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					 
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "6";
					timelist.add(questiontime);
					totalTime += temptime;
					Log.e("test", totalTime+"");
				}
				}
				break;
			}
			
			question_num++;
			
			if(question_num>list.size()-1){
				new Handler().postDelayed(new Runnable() {
					
					@Override
					public void run() {
						tv_choice1.setClickable(false);
						tv_choice2.setClickable(false);
						tv_choice3.setClickable(false);
						mPopWindow1.dismiss();
						mPopWindow2.dismiss();
						mPopWindow3.dismiss();
//						Intent intent = new Intent(NewTestThirdActivity.this, Activity.class);
						
						//timelist  
//						startActivity(intent);
						Log.e("test", totalTime+"总时间");
						Log.e("test", "跳转成绩提交页");
						for (int i = 0; i < timelist.size(); i++) {
							Log.e("test", timelist.get(i).qa_answer+"答案");
							Log.e("test", timelist.get(i).qa_time+"时间");
							Log.e("test", timelist.get(i).question_type+"type");
							Log.e("test", timelist.get(i).question_id+"id");
							
						}
						NormalDialogCustomAttr();
					}
				}, 1000);
				
			}else{
				question_type = list.get(question_num).question_type;
				message4 =null;
				message4 = Message.obtain();
				message4.what = 5;
				handler.sendMessageDelayed(message4, 1000);
			}
			
			break;
		case R.id.tv_type5_del: // 题型5删除按钮
			letter = ""; 
			typefivelist.remove(typefivelist.size()-1) ;
			for (int i = 0; i < typefivelist.size(); i++) {
				letter += typefivelist.get(i)+" ";
			}
			
			if(array==null){
				array ="";
			}else{
				array = array.substring(0, array.length()-1);
			}
			Log.e("test", letter);
			Log.e("test", array);
			new Handler().post(new Runnable() {
				
				@Override
				public void run() {
					tv_board.setText(letter);
					if("".equals(letter)){
						tv_type5_del.setVisibility(tv_type5_del.GONE);
					}
				}
			});
			
			
			break;
		case R.id.tv_true_bt: // 题型4true按钮
			
			if(type4==0){
				type4 = 1;
			if("right".equals(list.get(question_num).question_answer)){
				truepopwindow();
				score = score + 4;
				
				endDate = new Date(System.currentTimeMillis());
				diff = endDate.getTime() - curDate.getTime();
				int temptime = 0;
				if((diff/1000/100)>5){
					temptime = (int)(diff/1000) + 1;
				}else{
					temptime = (int)(diff/1000);
				}
				 
				if(temptime<1){
					temptime = 1;
				}
				QuestionTime questiontime = new QuestionTime();
				questiontime.qa_answer = "0";
				questiontime.qa_time = temptime+"";
				questiontime.question_id = list.get(question_num).question_id;
				questiontime.question_type = "4";
				timelist.add(questiontime);
				totalTime += temptime;
				Log.e("test", totalTime+"");
				
			}else{
				falsepopwindow();
				
				endDate = new Date(System.currentTimeMillis());
				diff = endDate.getTime() - curDate.getTime();
				int temptime = 0;
				if((diff/1000/100)>5){
					temptime = (int)(diff/1000) + 1;
				}else{
					temptime = (int)(diff/1000);
				}
				 
				if(temptime<1){
					temptime = 1;
				}
				QuestionTime questiontime = new QuestionTime();
				questiontime.qa_answer = "1";
				questiontime.qa_time = temptime+"";
				questiontime.question_id = list.get(question_num).question_id;
				questiontime.question_type = "4";
				timelist.add(questiontime);
				totalTime += temptime;
				Log.e("test", totalTime+"");
			}
			question_num++;
			question_type = list.get(question_num).question_type;
			message4 =null;
			message4 = Message.obtain();
			if ("4".equals(question_type)) {
				message4.what = 3;
			} else if ("5".equals(question_type)) {
				message4.what = 4;
			}
			handler.sendMessageDelayed(message4, 1000);
			}
			break;
		case R.id.tv_false_bt: // 题型4false按钮
			
			
			if(type4==0){
				type4 = 1;
			if("wrong".equals(list.get(question_num).question_answer)){
				truepopwindow();
				score = score + 4;
				
				endDate = new Date(System.currentTimeMillis());
				diff = endDate.getTime() - curDate.getTime();
				int temptime = 0;
				if((diff/1000/100)>5){
					temptime = (int)(diff/1000) + 1;
				}else{
					temptime = (int)(diff/1000);
				}
				 
				if(temptime<1){
					temptime = 1;
				}
				QuestionTime questiontime = new QuestionTime();
				questiontime.qa_answer = "0";
				questiontime.qa_time = temptime+"";
				questiontime.question_id = list.get(question_num).question_id;
				questiontime.question_type = "4";
				timelist.add(questiontime);
				totalTime += temptime;
				Log.e("test", totalTime+"");
				
			}else{
				falsepopwindow();
				
				endDate = new Date(System.currentTimeMillis());
				diff = endDate.getTime() - curDate.getTime();
				int temptime = 0;
				if((diff/1000/100)>5){
					temptime = (int)(diff/1000) + 1;
				}else{
					temptime = (int)(diff/1000);
				}
				 
				if(temptime<1){
					temptime = 1;
				}
				QuestionTime questiontime = new QuestionTime();
				questiontime.qa_answer = "1";
				questiontime.qa_time = temptime+"";
				questiontime.question_id = list.get(question_num).question_id;
				questiontime.question_type = "4";
				timelist.add(questiontime);
				totalTime += temptime;
				Log.e("test", totalTime+"");
			}
			question_num++;
			question_type = list.get(question_num).question_type;
			message4 =null;
			message4 = Message.obtain();
			if ("4".equals(question_type)) {
				message4.what = 3;
			} else if ("5".equals(question_type)) {
				message4.what = 4;
			}
			handler.sendMessageDelayed(message4, 1000);
			
			}
			break;
		case R.id.tv_del: // 题型3删除按钮
			
			letter = letter.substring(0, letter.length()-1);
			if(letter==null){
				letter = "";
			}
			new Handler().postDelayed(new Runnable() {
				
				@Override
				public void run() {
					// TODO Auto-generated method stub
					if("".equals(letter)){
	            		tv_del.setVisibility(tv_del.GONE);
	            	}
	            	tv_showword.setText(letter);
				}
			}, 0);
			
			
			break;
		case R.id.tv_check: // 题型3提交按钮
			
			if("".equals(letter)){
				nullpopwindow();
				new Handler().postDelayed(new Runnable() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
						mPopWindow2.dismiss();
					}
				}, 800);
				break;
			}
			
			if(letter.equals(list.get(question_num).question_answer)){
				truepopwindow();
				score = score + 4;
				
				endDate = new Date(System.currentTimeMillis());
				diff = endDate.getTime() - curDate.getTime();
				int temptime = 0;
				if((diff/1000/100)>5){
					temptime = (int)(diff/1000) + 1;
				}else{
					temptime = (int)(diff/1000);
				}
				 
				if(temptime<1){
					temptime = 1;
				}
				QuestionTime questiontime = new QuestionTime();
				questiontime.qa_answer = "0";
				questiontime.qa_time = temptime+"";
				questiontime.question_id = list.get(question_num).question_id;
				questiontime.question_type = "3";
				timelist.add(questiontime);
				totalTime += temptime;
				Log.e("test", totalTime+"");
			}else{ 
				falsepopwindow();
				endDate = new Date(System.currentTimeMillis());
				diff = endDate.getTime() - curDate.getTime();
				int temptime = 0;
				if((diff/1000/100)>5){
					temptime = (int)(diff/1000) + 1;
				}else{
					temptime = (int)(diff/1000);
				}
				 
				if(temptime<1){
					temptime = 1;
				}
				QuestionTime questiontime = new QuestionTime();
				questiontime.qa_answer = "1";
				questiontime.qa_time = temptime+"";
				questiontime.question_id = list.get(question_num).question_id;
				questiontime.question_type = "3";
				timelist.add(questiontime);
				totalTime += temptime;
				Log.e("test", totalTime+"");
			}
			letter = "";
			question_num++;
			question_type = list.get(question_num).question_type;
			Message message3 = Message.obtain();
			if ("3".equals(question_type)) {
				message3.what = 2;
			} else if ("4".equals(question_type)) {
				message3.what = 3;
			}
			handler.sendMessageDelayed(message3, 1000);
			break;
			
		case R.id.tv_player: // 音频播放按钮
			Log.e("test", audio_url + "");
			if (mediaPlayer != null) {
				mediaPlayer.stop();
				mediaPlayer.release();
				mediaPlayer = null;
				System.gc();
			}

			if (mediaPlayer == null) {
				
				if(audio_url!=null){
					if(!"".equals(audio_url)){
						mediaPlayer = MediaPlayer.create(this, Uri.parse(audio_url));
					}else{
						Toast.makeText(this, "当前网络状况差，请稍后重试", 0).show();
						return;
					}
					
				}else{
					Toast.makeText(this, "播放设备初始化失败，请退出后重试", 0).show();
					return;
				}
			
			}

			try {
				mediaPlayer.start();
				mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
					@Override
					public void onCompletion(MediaPlayer mp) {
						mediaPlayer.stop();
						mediaPlayer.release();
						mediaPlayer = null;
						System.gc();
					}
				});

			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (IllegalStateException e) {
				e.printStackTrace();
			}

			break;
		case R.id.iv_type1_img1:
			iv_type1_img1.setClickable(false);
			iv_type1_img2.setClickable(false);
			iv_type1_img3.setClickable(false);
			iv_type1_img4.setClickable(false);
			// 判断正误
			trueorfalse();
			if (question_answer != null && answer1 != null) {
				if (question_answer.equals(answer1)) {
					truepopwindow();
					score += 4;

						endDate = new Date(System.currentTimeMillis());
						diff = endDate.getTime() - curDate.getTime();
						int temptime = 0;
						if((diff/1000/100)>5){
							temptime = (int)(diff/1000) + 1;
						}else{
							temptime = (int)(diff/1000);
						}
						 
						if(temptime<1){
							temptime = 1;
						}
						QuestionTime questiontime = new QuestionTime();
						questiontime.qa_answer = "0";
						questiontime.qa_time = temptime+"";
						questiontime.question_id = list.get(question_num).question_id;
						questiontime.question_type = "1";
						timelist.add(questiontime);
						totalTime += temptime;
				} else {
					falsepopwindow();
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
				}

				question_num++;
				question_type = list.get(question_num).question_type;
				Message message = Message.obtain();
				if ("1".equals(question_type)) {
					message.what = 0;
				} else if ("2".equals(question_type)) {
					message.what = 1;
				}
				handler.sendMessageDelayed(message, 1000);
			} else {
				Toast.makeText(this, "网络连接异常，请稍后重试", 0).show();
			}
			
			break;
		case R.id.iv_type1_img2:
			iv_type1_img1.setClickable(false);
			iv_type1_img2.setClickable(false);
			iv_type1_img3.setClickable(false);
			iv_type1_img4.setClickable(false);
			// 判断正误
			trueorfalse();

			if (question_answer != null && answer2 != null) {
				if (question_answer.equals(answer2)) { // 正确
					truepopwindow();
					score += 4;
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "0";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
				} else { // 错误
					falsepopwindow();
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
				}

				question_num++;
				question_type = list.get(question_num).question_type;
				Message message = Message.obtain();
				if ("1".equals(question_type)) {
					message.what = 0;
				} else if ("2".equals(question_type)) {
					message.what = 1;
				}
				handler.sendMessageDelayed(message, 1000);
			} else {
				Toast.makeText(this, "网络连接异常，请稍后重试", 0).show();
			}
			break;
		case R.id.iv_type1_img3:

			iv_type1_img1.setClickable(false);
			iv_type1_img2.setClickable(false);
			iv_type1_img3.setClickable(false);
			iv_type1_img4.setClickable(false);
			// 判断正误
			trueorfalse();
			if (question_answer != null && answer3 != null) {
				if (question_answer.equals(answer3)) {
					truepopwindow();
					score += 4;
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "0";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
				} else {
					
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
					falsepopwindow();
				}
				question_num++;
				question_type = list.get(question_num).question_type;

				Message message = Message.obtain();

				if ("1".equals(question_type)) {
					message.what = 0;
				} else if ("2".equals(question_type)) {
					message.what = 1;
				}

				handler.sendMessageDelayed(message, 1000);
			} else {
				Toast.makeText(this, "网络连接异常，请稍后重试", 0).show();
			}
			break;
		case R.id.iv_type1_img4:
			iv_type1_img1.setClickable(false);
			iv_type1_img2.setClickable(false);
			iv_type1_img3.setClickable(false);
			iv_type1_img4.setClickable(false);
			// 判断正误
			trueorfalse();
			if (question_answer != null && answer4 != null) {
				if (question_answer.equals(answer4)) {
					truepopwindow();
					score += 4;
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "0";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
				} else {
					endDate = new Date(System.currentTimeMillis());
					diff = endDate.getTime() - curDate.getTime();
					int temptime = 0;
					if((diff/1000/100)>5){
						temptime = (int)(diff/1000) + 1;
					}else{
						temptime = (int)(diff/1000);
					}
					if(temptime<1){
						temptime = 1;
					}
					QuestionTime questiontime = new QuestionTime();
					questiontime.qa_answer = "1";
					questiontime.qa_time = temptime+"";
					questiontime.question_id = list.get(question_num).question_id;
					questiontime.question_type = "1";
					timelist.add(questiontime);
					falsepopwindow();
				}

				question_num++;
				question_type = list.get(question_num).question_type;

				Message message = Message.obtain();
				if ("1".equals(question_type)) {
					message.what = 0;
				} else if ("2".equals(question_type)) {
					message.what = 1;
				}

				handler.sendMessageDelayed(message, 1000);
			} else {
				Toast.makeText(this, "网络连接异常，请稍后重试", 0).show();
			}
			break;
		case R.id.iv_share:// 分享
			if ("".equals(Score) && "".equals(Time)) {
//				deleteShare();
				clickShare(v);
			} else {
				clickShare2();
			}
			break;
		}
	}

	private void trueorfalse() {

		iv_type1_tf1.setVisibility(iv_type1_tf1.VISIBLE);
		iv_type1_tf2.setVisibility(iv_type1_tf2.VISIBLE);
		iv_type1_tf3.setVisibility(iv_type1_tf3.VISIBLE);
		iv_type1_tf4.setVisibility(iv_type1_tf4.VISIBLE);

		if (question_answer.equals(answer1)) {
			iv_type1_tf1.setImageDrawable(this.getResources().getDrawable(
					R.drawable.ture_img));
			iv_type1_tf2.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf3.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf4.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
		} else if (question_answer.equals(answer2)) {
			iv_type1_tf1.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf2.setImageDrawable(this.getResources().getDrawable(
					R.drawable.ture_img));
			iv_type1_tf3.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf4.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
		} else if (question_answer.equals(answer3)) {
			iv_type1_tf1.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf2.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf3.setImageDrawable(this.getResources().getDrawable(
					R.drawable.ture_img));
			iv_type1_tf4.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
		} else if (question_answer.equals(answer4)) {
			iv_type1_tf1.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf2.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf3.setImageDrawable(this.getResources().getDrawable(
					R.drawable.false_img));
			iv_type1_tf4.setImageDrawable(this.getResources().getDrawable(
					R.drawable.ture_img));
		}
	}

	private void falsepopwindow() {

		mPopWindow3.showAtLocation(rootview, Gravity.CENTER, 0, 0);
		String path="http://m.moregolden.com:8080/html5/mp3/errorMp3.mp3";
		showToast(path);
	}

	private void truepopwindow() {

		mPopWindow1.showAtLocation(rootview, Gravity.CENTER, 0, 0);
		String path="http://m.moregolden.com:8080/html5/mp3/rightMp3.mp3";
		showToast(path);
	}

	private void nullpopwindow() {

		mPopWindow2.showAtLocation(rootview, Gravity.CENTER, 0, 0);

	}

	private void initData() {
		iv_type1_img1.setClickable(false);
		iv_type1_img2.setClickable(false);
		iv_type1_img3.setClickable(false);
		iv_type1_img4.setClickable(false);
		tv_player.setClickable(false);

		OkHttpClient mOkHttpClient = new OkHttpClient();
		final Request request = new Request.Builder()
				.url(NetConstant.HOST2+"Test_Bank/UnitTest/GetLessonPracticeQuestion.aspx?lessonid="
						+ lESSON_ID + "&account=" + account).build();
		// http://m.moregolden.com:6060/
		Call call = mOkHttpClient.newCall(request);
		call.enqueue(callBack);

	}

	Callback callBack = new Callback() {

		@Override
		public void onFailure(Request arg0, IOException arg1) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void onResponse(Response arg0) throws IOException {
			// TODO Auto-generated method stub
			String json = arg0.body().string();
			Log.e("test", json);
			Gson gson = new Gson();
			NewTestResp fromJson = gson.fromJson(json, NewTestResp.class);
			question_count = fromJson.question_list_count; // 题目数
			list = new ArrayList<QuestionInfo>();
			list = fromJson.question_list; // 所有题目
			mAdapter = new MatchAdapter();
			mAdapter1 = new LetterAdapter();
			mAdapter5 = new TypefiveAdapter();
			Message message = Message.obtain();
			message.what = 0;
			message.obj = fromJson;
			handler.sendMessage(message);
		}

		
	};

	public class MyHandler extends Handler {

		private final WeakReference<NewTestThirdActivity> mActivity;

		public MyHandler(NewTestThirdActivity activity) {
			mActivity = new WeakReference<NewTestThirdActivity>(activity);
		}

		@Override
		public void handleMessage(Message msg) {
			NewTestThirdActivity activity = mActivity.get();
			if (activity == null) {
				super.handleMessage(msg);
				return;
			}
			mPopWindow1.dismiss();
			mPopWindow2.dismiss();
			mPopWindow3.dismiss();
			isfavor=false;
			String favor_status = list.get(question_num).favor_status;
			if("1".equals(favor_status)){
				isfavor=true;
				tv_shoucang.setBackgroundResource(R.drawable.nav_collect_ed2x);
//				tv_shoucang.setChecked(true);
			}else {
				isfavor=false;
				tv_shoucang.setBackgroundResource(R.drawable.nav_collect2x);
//				tv_shoucang.setChecked(false);
			}
			switch (msg.what) {
			case 0: // 题型1
				
				curDate = new Date(System.currentTimeMillis());   //开始计时
				
				
				int y = 0;
				tv_player.setClickable(true);
				iv_type1_img1.setClickable(true);
				iv_type1_img2.setClickable(true);
				iv_type1_img3.setClickable(true);
				iv_type1_img4.setClickable(true);
				iv_type1_tf1.setVisibility(iv_type1_tf1.GONE);
				iv_type1_tf2.setVisibility(iv_type1_tf2.GONE);
				iv_type1_tf3.setVisibility(iv_type1_tf3.GONE);
				iv_type1_tf4.setVisibility(iv_type1_tf4.GONE);

				progress_bar.setProgress(question_num + 1);
				question_answer = list.get(question_num).question_answer;// 答案
				tv_score.setText(score + ".0分");
				tv_pager.setText((question_num + 1) + "/" + question_count);
				tv_shoucang.setText((question_num + 1) + "");

				for (int i = 0; i < list.get(question_num).detail_list.size(); i++) {
					if ("2".equals(list.get(question_num).detail_list.get(i).detail_type_id)) {
						switch (y) {
						case 0:
							Picasso.with(NewTestThirdActivity.this)
									.load(list.get(question_num).detail_list
											.get(i).detail_content)
									.into(iv_type1_img1);

							String str1 = list.get(question_num).detail_list
									.get(i).detail_content;
							answer1 = str1
									.substring(str1.indexOf("/image/") + 7);

							y++;
							break;
						case 1:
							Picasso.with(NewTestThirdActivity.this)
									.load(list.get(question_num).detail_list
											.get(i).detail_content)
									.into(iv_type1_img2);

							String str2 = list.get(question_num).detail_list
									.get(i).detail_content;
							answer2 = str2
									.substring(str2.indexOf("/image/") + 7);

							y++;
							break;
						case 2:
							Picasso.with(NewTestThirdActivity.this)
									.load(list.get(question_num).detail_list
											.get(i).detail_content)
									.into(iv_type1_img3);

							String str3 = list.get(question_num).detail_list
									.get(i).detail_content;
							answer3 = str3
									.substring(str3.indexOf("/image/") + 7);

							y++;
							
							break;
						case 3:
							Picasso.with(NewTestThirdActivity.this)
									.load(list.get(question_num).detail_list
											.get(i).detail_content)
									.into(iv_type1_img4);

							String str4 = list.get(question_num).detail_list
									.get(i).detail_content;
							answer4 = str4
									.substring(str4.indexOf("/image/") + 7);

							y++;
							break;
						default:
							break;
						}

					} else if ("1".equals(list.get(question_num).detail_list
							.get(i).detail_type_id)) {
						audio_url = list.get(question_num).detail_list.get(i).detail_content;
					}
				}

				break;
			case 1: // 题型2
				
				curDate = new Date(System.currentTimeMillis());   //开始计时
				progress_bar.setProgress(question_num + 1); // 进度条
				tv_player_img.setVisibility(tv_player_img.GONE);// 喇叭
				tv_score.setText(score + ".0分"); // 成绩
				ll_type1.setVisibility(ll_type1.GONE);
				ll_type2.setVisibility(ll_type2.VISIBLE);
				tv_text.setVisibility(tv_text.GONE);
				tv_pager.setText((question_num + 1) + "/" + question_count);// 题号
				tv_shoucang.setText((question_num + 1) + ""); // 收藏
				tv_player.setText(list.get(question_num).question_type_name);
				tv_player.setClickable(false);

				detaillist = list.get(question_num).detail_list;
				dismissedlist = new ArrayList<Integer>();
				dismissedlist.add(-1);

				if (list.get(question_num).detail_list.size() > 11) {

					if (!detaillist.isEmpty()) {
						for (int i = 0; i < detaillist.size(); i++) {
							for (int j = i + 1; j < detaillist.size(); j++) {
								if (detaillist.get(i).question_content
										.equals(detaillist.get(j).question_content)) {
									detaillist.remove(j);
								}
							}
						}
					}
				}
				
				gv_match.setAdapter(mAdapter);
				gv_match.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						for (int i = 0; i < dismissedlist.size(); i++) {
							if (dismissedlist.get(i) == position) {
								return;
							}
						}

						if (Click == 1) { // 第1次点击

							tv_word1 = (TextView) view
									.findViewById(R.id.tv_word);
							word1 = tv_word1.getText().toString();
							if (isContainChinese(word1)) {// 判断
								ClickType1 = 0; // 汉字
							} else {
								ClickType1 = 1; // 英文
							}
							tv_word1.setBackground(NewTestThirdActivity.this
									.getResources().getDrawable(
											R.drawable.shape_red_word));
							Click++;
							p = position;

						} else if (Click == 2) { // 第2次点击
							if (p != position) {
								tv_word2 = (TextView) view
										.findViewById(R.id.tv_word);
								word2 = tv_word2.getText().toString();
								if (isContainChinese(word2)) {
									ClickType2 = 0;
								} else {
									ClickType2 = 1;
								}

								if (ClickType1 == ClickType2) {
									Click = 2;
									p = position;

									if (isContainChinese(word1)) {
										tv_word1.setBackground(NewTestThirdActivity.this
												.getResources()
												.getDrawable(
														R.drawable.shape_blue_word));
									} else {
										tv_word1.setBackground(NewTestThirdActivity.this
												.getResources()
												.getDrawable(
														R.drawable.shape_purple_word));
									}
									tv_word1 = (TextView) view
											.findViewById(R.id.tv_word);
									word1 = tv_word1.getText().toString();

									tv_word1.setBackground(NewTestThirdActivity.this
											.getResources().getDrawable(
													R.drawable.shape_red_word));
									return;
								}

								gv_match.setClickable(false);
								Click = 1;

								if (word1.equals(list.get(question_num).detail_list
										.get(position).question_answer)) {
									truepopwindow();
									tv_word1.setVisibility(tv_word1.INVISIBLE);
									tv_word2.setVisibility(tv_word2.INVISIBLE);
									dismissedlist.add(p);
									dismissedlist.add(position);
								} else {
									falsepopwindow();
									alltrue = 1;
									tv_word1.setVisibility(tv_word1.INVISIBLE);
									tv_word2.setVisibility(tv_word2.INVISIBLE);
									dismissedlist.add(p);
									dismissedlist.add(position);
								}

								if (dismissedlist.size() > detaillist.size()) { // 全部消除完
									
									
									String answer = "1";
									if (alltrue == 0) {
										score += 4;
										answer = "0";
									}
									
									endDate = new Date(System.currentTimeMillis());
									diff = endDate.getTime() - curDate.getTime();
									int temptime = 0;
									if((diff/1000/100)>5){
										temptime = (int)(diff/1000) + 1;
									}else{
										temptime = (int)(diff/1000);
									}
									 
									if(temptime<1){
										temptime = 1;
									}
									
									QuestionTime questiontime = new QuestionTime();
									questiontime.qa_answer = answer;
									questiontime.qa_time = temptime+"";
									questiontime.question_id = list.get(question_num).question_id;
									questiontime.question_type = "2";
									timelist.add(questiontime);
									totalTime += temptime;
									Log.e("test", totalTime+"");
									
									alltrue = 0;
									question_num++;
									question_type = list.get(question_num).question_type;

									Message message = Message.obtain();
									if ("2".equals(question_type)) {
										message.what = 1;
									} else if ("3".equals(question_type)) {
										message.what = 2;
									}
									handler.sendMessageDelayed(message, 1000);
								}

								postDelayed(new Runnable() {
									@Override
									public void run() {
										gv_match.setClickable(true);
										mPopWindow1.dismiss();
										mPopWindow2.dismiss();
										mPopWindow3.dismiss();
									}
								}, 1000);

							} else {// 重复点击
								Click = 1;
								word1 = tv_word1.getText().toString();
								if (isContainChinese(word1)) {
									tv_word1.setBackground(NewTestThirdActivity.this
											.getResources().getDrawable(
													R.drawable.shape_blue_word));
								} else {
									tv_word1.setBackground(NewTestThirdActivity.this
											.getResources()
											.getDrawable(
													R.drawable.shape_purple_word));
								}
							}
						}
					}
				});

				break;
			case 2: // 题型3
				
				curDate = new Date(System.currentTimeMillis());   //开始计时
				tv_showword.setText(letter);
				tv_del.setVisibility(tv_del.GONE);
				tv_player_img.setVisibility(tv_player_img.VISIBLE);// 喇叭
				ll_type2.setVisibility(ll_type2.GONE);
				ll_type3.setVisibility(ll_type3.VISIBLE);
				progress_bar.setProgress(question_num + 1); // 进度条
				tv_score.setText(score + ".0分"); // 成绩
				tv_pager.setText((question_num + 1) + "/" + question_count);// 题号
				tv_shoucang.setText((question_num + 1) + ""); // 收藏
				tv_player.setText("请点击喇叭播放");
				tv_player.setClickable(true);

				String str = list.get(question_num).question_content;
				Letterlist = new ArrayList<String>();
				for (int i = 0; i < str.length(); i++) {
					Letterlist.add(str.substring(i, i + 1));
				}
				for (int i = 0; i < list.get(question_num).detail_list.size(); i++) {
					if("2".equals(list.get(question_num).detail_list.get(i).detail_type_id)){
						Picasso.with(NewTestThirdActivity.this)
						.load(list.get(question_num).detail_list.get(i).detail_content)
						.into(iv_type3_img);
					}else if("1".equals(list.get(question_num).detail_list.get(i).detail_type_id)){
						audio_url = list.get(question_num).detail_list.get(i).detail_content;
					}
				}
				
				gv_letter.setAdapter(mAdapter1);
				gv_letter.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						if("".equals(letter)){
							tv_del.setVisibility(tv_del.VISIBLE);
						}
						letter = letter + Letterlist.get(position);
						tv_showword.setText(letter);
					}
				});
				
				break;
			case 3: // 题型4
				type4 = 0;
				
				curDate = new Date(System.currentTimeMillis());   //开始计时
				
				tv_player_img.setVisibility(tv_player_img.GONE);// 喇叭
				ll_type3.setVisibility(ll_type3.GONE);
				ll_type4.setVisibility(ll_type4.VISIBLE);
				progress_bar.setProgress(question_num + 1); // 进度条
				tv_score.setText(score + ".0分"); // 成绩
				tv_pager.setText((question_num + 1) + "/" + question_count);// 题号
				tv_shoucang.setText((question_num + 1) + ""); // 收藏
				tv_player.setText(list.get(question_num).question_content);
				tv_player.setClickable(false);
				
				Picasso.with(NewTestThirdActivity.this)
				.load(list.get(question_num).detail_list.get(0).detail_content)
				.into(iv_type4_img);
				
				break;
			case 4: // 题型5
				
				curDate = new Date(System.currentTimeMillis());   //开始计时
				
				tv_type5_del.setVisibility(tv_type5_del.GONE);
				ll_type4.setVisibility(ll_type4.GONE);
				ll_type5.setVisibility(ll_type5.VISIBLE);
				progress_bar.setProgress(question_num + 1); 				// 进度条
				tv_score.setText(score + ".0分"); 							// 成绩
				tv_pager.setText((question_num + 1) + "/" + question_count);// 题号
				tv_shoucang.setText((question_num + 1) + ""); 				// 收藏
				tv_player.setText(list.get(question_num).question_type_name);
				
				letter = "";
				array = "";
				tv_board.setText(letter);
				typefivelist = new ArrayList<String>();
				mAdapter5 = new TypefiveAdapter();
				gv_type5.setAdapter(mAdapter5);
				gv_type5.setOnItemClickListener(new OnItemClickListener() {

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						if("".equals(letter)){
							tv_type5_del.setVisibility(tv_type5_del.VISIBLE);
						}
						typefivelist.add(list.get(question_num).detail_list.get(position).question_content);
//						for (int i = 0; i < typefivelist.size(); i++) {
							letter = letter + typefivelist.get(typefivelist.size()-1)+" ";
//						}
							if(list.get(question_num).detail_list.size()<typefivelist.size()){
								return;
							}
						tv_board.setText(letter);
						array += list.get(question_num).detail_list.get(position).question_answer;
						Log.e("test1", array);
						if(list.get(question_num).detail_list.size()==typefivelist.size()){//提交
							String truearray = "";
							if(array.length()<10){
								for (int j = 0; j < array.length(); j++) {
									truearray = truearray + (j+1);
								}
							}else if(array.length()==11){
								for (int j = 0; j < array.length()-1; j++) {
									truearray = truearray + (j+1);
								}
							}else if(array.length()==13){
								for (int j = 0; j < array.length()-2; j++) {
									truearray = truearray + (j+1);
								}
							}else if(array.length()==15){
								for (int j = 0; j < array.length()-3; j++) {
									truearray = truearray + (j+1);
								}
							}else if(array.length()==17){
								for (int j = 0; j < array.length()-4; j++) {
									truearray = truearray + (j+1);
								}
							}else if(array.length()==19){
								for (int j = 0; j < array.length()-5; j++) {
									truearray = truearray + (j+1);
								}
							}
							
							Log.e("test2", truearray);
							if(truearray.equals(array)){//判断正误
								
								truepopwindow();
								score = score + 4;
								endDate = new Date(System.currentTimeMillis());
								diff = endDate.getTime() - curDate.getTime();
								int temptime = 0;
								if((diff/1000/100)>5){
									temptime = (int)(diff/1000) + 1;
								}else{
									temptime = (int)(diff/1000);
								}
								 
								if(temptime<1){
									temptime = 1;
								}
								QuestionTime questiontime = new QuestionTime();
								questiontime.qa_answer = "0";
								questiontime.qa_time = temptime+"";
								questiontime.question_id = list.get(question_num).question_id;
								questiontime.question_type = "5";
								timelist.add(questiontime);
								totalTime += temptime;
								Log.e("test", totalTime+"");
								
							}else{
								falsepopwindow();
								
								endDate = new Date(System.currentTimeMillis());
								diff = endDate.getTime() - curDate.getTime();
								int temptime = 0;
								if((diff/1000/100)>5){
									temptime = (int)(diff/1000) + 1;
								}else{
									temptime = (int)(diff/1000);
								}
								 
								if(temptime<1){
									temptime = 1;
								}
								QuestionTime questiontime = new QuestionTime();
								questiontime.qa_answer = "1";
								questiontime.qa_time = temptime+"";
								questiontime.question_id = list.get(question_num).question_id;
								questiontime.question_type = "5";
								timelist.add(questiontime);
								totalTime += temptime;
								Log.e("test", totalTime+"");
							}
							
							question_num++;
							question_type = list.get(question_num).question_type;
							message4 =null;
							message4 = Message.obtain();
							if ("5".equals(question_type)) {
								message4.what = 4;
							} else if ("6".equals(question_type)) {
								message4.what = 5;
							}
							handler.sendMessageDelayed(message4, 1000);
							

							
						}
					}
				});
				
				break;
			case 5: // 题型6
				tv_choice1.setClickable(true);
				tv_choice2.setClickable(true);
				tv_choice3.setClickable(true);
				curDate = new Date(System.currentTimeMillis());   //开始计时
				
				Log.e("test", list.get(question_num).question_answer);
				ll_type5.setVisibility(ll_type5.GONE);
				ll_type6.setVisibility(ll_type6.VISIBLE);
				progress_bar.setProgress(question_num + 1); 				// 进度条
				tv_score.setText(score + ".0分"); 							// 成绩
				tv_pager.setText((question_num + 1) + "/" + question_count);// 题号
				tv_shoucang.setText((question_num + 1) + ""); 				// 收藏
				tv_player.setText(list.get(question_num).question_content);
				
				int j = 1;
				for (int i = 0; i < list.get(question_num).detail_list.size(); i++) {
					
					if("3".equals(list.get(question_num).detail_list.get(i).detail_type_id)){
						if(j==1){
							tv_choice1.setText(list.get(question_num).detail_list.get(i).detail_content);
							j++;
						}else if(j==2){
							tv_choice2.setText(list.get(question_num).detail_list.get(i).detail_content);
							j++;
						}else if(j==3){
							tv_choice3.setText(list.get(question_num).detail_list.get(i).detail_content);
							j++;
						}
					}
					if("2".equals(list.get(question_num).detail_list.get(i).detail_type_id)){
						Picasso.with(NewTestThirdActivity.this)
						.load(list.get(question_num).detail_list.get(i).detail_content)
						.into(iv_type6_img);
						
					}
				}
				
				
				break;
			default:
				super.handleMessage(msg);
				break;
			}
		}
	}

	// 是否包含汉字
	public static boolean isContainChinese(String str) {

		Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
		Matcher m = p.matcher(str);
		if (m.find()) {
			return true;
		}
		return false;
	}
	class LetterAdapter extends BaseAdapter {

		public int getCount() {

			return Letterlist.size();
		}

		public Object getItem(int position) {

			return null;
		}

		public long getItemId(int position) {

			return 0;
		}

		ViewHolder vh = null;

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = View.inflate(parent.getContext(),
						R.layout.item_letter, null);
				vh = new ViewHolder();
				vh.tv_letter = (TextView) convertView.findViewById(R.id.tv_letter);
				convertView.setTag(vh);
			} else {
				vh = (ViewHolder) convertView.getTag();
			}

			vh.tv_letter.setText(Letterlist.get(position));
			if("".equals(Letterlist.get(position))){
				vh.tv_letter.setText("_");
			}
			return convertView;
		}

		class ViewHolder {
			private TextView tv_letter;
		}
	}
	
	
	class MatchAdapter extends BaseAdapter {

		public int getCount() {

			return detaillist.size();
		}

		public Object getItem(int position) {

			return null;
		}

		public long getItemId(int position) {

			return 0;
		}

		ViewHolder vh = null;

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = View.inflate(parent.getContext(),
						R.layout.item_match, null);
				vh = new ViewHolder();
				vh.tv_word = (TextView) convertView.findViewById(R.id.tv_word);
				convertView.setTag(vh);
			} else {
				vh = (ViewHolder) convertView.getTag();
			}

			vh.tv_word.setText(detaillist.get(position).question_content);
			if (isContainChinese(detaillist.get(position).question_content)) {
				vh.tv_word
						.setBackground(NewTestThirdActivity.this.getResources()
								.getDrawable(R.drawable.shape_blue_word));
			} else {

				vh.tv_word.setBackground(NewTestThirdActivity.this
						.getResources().getDrawable(
								R.drawable.shape_purple_word));
			}
			return convertView;
		}

		class ViewHolder {
			private TextView tv_word;
		}
	}

	class TypefiveAdapter extends BaseAdapter {

		public int getCount() {

			return list.get(question_num).detail_list.size();
		}

		public Object getItem(int position) {

			return null;
		}

		public long getItemId(int position) {

			return 0;
		}

		ViewHolder vh = null;

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = View.inflate(parent.getContext(),
						R.layout.item_match, null);
				vh = new ViewHolder();
				vh.tv_word = (TextView) convertView.findViewById(R.id.tv_word);
				convertView.setTag(vh);
			} else {
				vh = (ViewHolder) convertView.getTag();
			}

			vh.tv_word.setText(list.get(question_num).detail_list.get(position).question_content);
			if (position%2==0) {
				vh.tv_word
						.setBackground(NewTestThirdActivity.this.getResources()
								.getDrawable(R.drawable.shape_blue_word));
			} else {

				vh.tv_word.setBackground(NewTestThirdActivity.this
						.getResources().getDrawable(
								R.drawable.shape_purple_word));
			}
			return convertView;
		}

		class ViewHolder {
			private TextView tv_word;
		}
	}
	
	@Override
	protected void onPause() {
		super.onPause();

		if (mediaPlayer != null) {
			mediaPlayer.pause();
		}
		HttpUtils httpUtils2 = new HttpUtils();
		httpUtils2.configCurrentHttpCacheExpiry(1000);
		httpUtils2.send(HttpMethod.GET,NetConstant.USERONLINE+ "SaveInterfaceEnd.aspx?msg=1&rid="+rid+"&account="
						+ SPUtils.getString(this,ConfigConstant.USERNAME)
										,callBackTimefinish);
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		if (mediaPlayer != null) {
			mediaPlayer.stop();
			mediaPlayer.release();
			mediaPlayer = null;
			System.gc();
		}
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		System.gc();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		
		String gradeid=String.valueOf(lESSON_ID).substring(0, 4) ;
		HttpUtils httpUtils2 = new HttpUtils();
		httpUtils2.configCurrentHttpCacheExpiry(1000);
		httpUtils2.send(HttpMethod.GET,NetConstant.USERONLINE+ "InitInterfaceBegin.aspx?msg=1&type=1&account="
						+ SPUtils.getString(this,ConfigConstant.USERNAME)+ "&gradeid="+gradeid+"&lessonid="+lESSON_ID
										,callBackTime);
		
	}

	public int getPhoneSDKInt() {
		int version = 0;
		try {
			version = Integer.valueOf(Build.VERSION.SDK);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return version;
	}

	@TargetApi(19)
	private void setTranslucentStatus(boolean on) {
		Window win = getWindow();
		WindowManager.LayoutParams winParams = win.getAttributes();
		final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
		if (on) {
			winParams.flags |= bits;
		} else {
			winParams.flags &= ~bits;
		}
		win.setAttributes(winParams);
	}

	@Override
	public void finish() {
		ViewGroup view = (ViewGroup) getWindow().getDecorView();
		view.removeAllViews();
		super.finish();
	}

	public void clickShare(View v) {
		// 得到当前view所在view结构中的根view
		View vv = v.getRootView();
		// 设置属性
		vv.setDrawingCacheEnabled(true);

		// 取得位图
		Bitmap bm = vv.getDrawingCache();

		Resources res = getResources();
		Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.ycsjlogo);
		Bitmap watermarkBitmap = watermarkBitmap(
				bm,
				bmp,
				"金牌君使用者："
						+ SPUtils.getString(NewTestThirdActivity.this, "name"));
		// iv.setImageBitmap(watermarkBitmap);
		try {
			saveFile(watermarkBitmap, "out.jpg");
			sharePic();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		vv.destroyDrawingCache();
	}

	/**
	 * 保存文件
	 * 
	 * @param bm
	 * @param fileName
	 * @throws IOException
	 */
	public void saveFile(Bitmap bm, String fileName) throws IOException {
		String path = getSDPath() + "/goldupload/";
		File dirFile = new File(path);
		if (!dirFile.exists()) {
			dirFile.mkdir();
		}

		File myCaptureFile = new File(path + fileName);
		BufferedOutputStream bos = new BufferedOutputStream(
				new FileOutputStream(myCaptureFile));
		bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
		bos.flush();
		bos.close();
	}

	public String getSDPath() {
		File sdDir = null;
		boolean sdCardExist = Environment.getExternalStorageState().equals(
				Environment.MEDIA_MOUNTED); // 判断sd卡是否存在
		if (sdCardExist) {
			sdDir = Environment.getExternalStorageDirectory();// 获取跟目录
		} else {
			sdDir = getFilesDir();
		}
		return sdDir.toString();
	}

	/**
	 * 加水印 也可以加文字
	 * 
	 * @param src
	 * @param watermark
	 * @param title
	 * @return
	 */
	public static Bitmap watermarkBitmap(Bitmap src, Bitmap watermark,
			String title) {
		if (src == null) {
			return null;
		}
		int w = src.getWidth();
		int h = src.getHeight();
		// 需要处理图片太大造成的内存超过的问题,这里我的图片很小所以不写相应代码了

		Bitmap newb = Bitmap.createBitmap(w, h, Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图
		Canvas cv = new Canvas(newb);
		cv.drawBitmap(src, 0, 0, null);// 在 0，0坐标开始画入src
		Paint paint = new Paint();
		// 加入图片
		if (watermark != null) {
			int ww = watermark.getWidth();
			int wh = watermark.getHeight();
			// paint.setAlpha(50);
			cv.drawBitmap(watermark, w - ww - 5, h * 3 / 4, paint);// 在src的右下角画入水印
			// cv.drawBitmap(watermark, 0, 0, paint);// 在src的左上角画入水印
		} else {
			Log.i("i", "water mark failed");
		}

		// 加入文字
		if (title != null) {
			String familyName = "宋体";
			Typeface font = Typeface.create(familyName, Typeface.NORMAL);
			TextPaint textPaint = new TextPaint();
			textPaint.setColor(Color.RED);
			// textPaint.setAlpha(52);
			textPaint.setTypeface(font);
			textPaint.setTextSize(20);
			// 这里是自动换行的
			// StaticLayout layout = new
			// StaticLayout(title,textPaint,w,Alignment.ALIGN_OPPOSITE,1.0F,0.0F,true);
			// layout.draw(cv);
			// 文字就加左上角算了
			cv.drawText(title, w / 5, h * 7 / 8, textPaint);
		}
		cv.save(Canvas.ALL_SAVE_FLAG);// 保存
		cv.restore();// 存储
		return newb;
	}

	public void sharePic() {
		// ShareSDK.initSDK(WordsFuxiActivity.this);
		MobSDK.init(NewTestThirdActivity.this, "12c24ea0b59b0",
				"aae63565fbd69b1acbfcdd0d5ac0b35c");
		OnekeyShare oks = new OnekeyShare();
		// 关闭sso授权
		oks.disableSSOWhenAuthorize();
		oks.setShareContentCustomizeCallback(new ShareContentCustomizeCallback() {

			@Override
			public void onShare(Platform platform, ShareParams paramsToShare) {
				 if (SinaWeibo.NAME.equals(platform.getName())) {
					paramsToShare.setText("");
					// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
					// oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
					// paramsToShare.setImageUrl("http://139.129.57.83:8080/Appandroid/APPicon192.png");
					// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
					paramsToShare.setImagePath(getSDPath()
							+ "/goldupload/out.jpg");// 确保SDcard下面存在此张图片
				} else if (QQ.NAME.equals(platform.getName())) {
					// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
					paramsToShare.setImagePath(getSDPath()
							+ "/goldupload/out.jpg");// 确保SDcard下面存在此张图片
					// oks.seti
					// url仅在微信（包括好友和朋友圈）中使用
					// oks.setUrl(list.get(0).WEB_URL);
					// 微信分享必须设置否则发送文本信息
					// oks.setImageUrl("http://f1.sharesdk.cn/imgs/2014/02/26/owWpLZo_638x960.jpg");
					paramsToShare
							.setImageUrl("http://139.129.57.83:8080/Appandroid/APPicon192.png");
					// comment是我对这条分享的评论，仅在人人网和QQ空间使用
					paramsToShare.setComment("");
					// site是分享此内容的网站名称，仅在QQ空间使用
					paramsToShare.setSite(getString(R.string.app_name));
					// siteUrl是分享此内容的网站地址，仅在QQ空间使用
					paramsToShare
							.setSiteUrl("http://139.129.57.83:8080/Appandroid/APPicon192.png");

				} else {
					paramsToShare.setShareType(Platform.SHARE_IMAGE);
					paramsToShare.setTitle("wer");
					// paramsToShare.setText("ces");
					// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
					paramsToShare.setImagePath(getSDPath()
							+ "/goldupload/out.jpg");// 确保SDcard下面存在此张图片
					// paramsToShare.setUrl("http://www.baidu.com");
					// paramsToShare.setImageUrl("http://f1.sharesdk.cn/imgs/2014/02/26/owWpLZo_638x960.jpg");
					// oks.seti
					// url仅在微信（包括好友和朋友圈）中使用
					// oks.setUrl(list.get(0).WEB_URL);
					// 微信分享必须设置否则发送文本信息
					// oks.setImageUrl("http://f1.sharesdk.cn/imgs/2014/02/26/owWpLZo_638x960.jpg");
					// comment是我对这条分享的评论，仅在人人网和QQ空间使用
					// paramsToShare.setComment("");
					// // site是分享此内容的网站名称，仅在QQ空间使用
					// paramsToShare.setSite(getString(R.string.app_name));
					// // siteUrl是分享此内容的网站地址，仅在QQ空间使用
					// paramsToShare.setSiteUrl("http://139.129.57.83:8080/Appandroid/APPicon192.png");

				}

			}
		});
		oks.show(NewTestThirdActivity.this);

	}

	public void deleteShare() {

		File f = new File(getSDPath() + "/goldupload/");

		File[] fl = f.listFiles();
		for (int i = 0; i < fl.length; i++) {
			if (fl[i].toString().endsWith("out.jpg")
					|| fl[i].toString().endsWith("out.jpg")) {
				if (fl[i].delete()) {
				} else {
				}
			}
		}
	}

	public void clickShare2() {
		// ShareSDK.initSDK(scoreReportActivity.this);
		MobSDK.init(NewTestThirdActivity.this, "12c24ea0b59b0",
				"aae63565fbd69b1acbfcdd0d5ac0b35c");
		OnekeyShare oks = new OnekeyShare();
		// 关闭sso授权
		oks.disableSSOWhenAuthorize();

		// 分享时Notification的图标和文字 2.5.9以后的版本不 调用此方法
		// oks.setNotification(R.drawable.ic_launcher,
		// getString(R.string.app_name));
		// title标题，印象笔记、邮箱、信息、微信、人人网和QQ空间使用
		oks.setTitle(getString(R.string.share));
		// titleUrl是标题的网络链接，仅在人人网和QQ空间使用
		oks.setTitleUrl("http://m.moregolden.com:36356/scorePage.html?moduleType=0&userType=0&time="
				+ Time
				+ "&mark="
				+ Score
				+ "&num="
				+ SPUtils.getString(this, ConfigConstant.USERNAME)
				+ "&exam_type=1");
		oks.setTitle(SPUtils.getString(this, "name") + "在金牌君自主检测环节获得" + Score
				+ "分,不要羡慕☺");
		// text是分享文本，所有平台都需要这个字段
		oks.setText("赶快来试试吧");
		// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
		// oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
		oks.setImageUrl("http://139.129.57.83:8080/Appandroid/APPicon192.png");
		// url仅在微信（包括好友和朋友圈）中使用
		oks.setUrl("http://m.moregolden.com:36356/scorePage.html?moduleType=0&userType=0&time="
				+ Time
				+ "&mark="
				+ Score
				+ "&num="
				+ SPUtils.getString(this, ConfigConstant.USERNAME)
				+ "&exam_type=1");
		// comment是我对这条分享的评论，仅在人人网和QQ空间使用
		oks.setComment("");
		// site是分享此内容的网站名称，仅在QQ空间使用
		oks.setSite(getString(R.string.app_name));
		// siteUrl是分享此内容的网站地址，仅在QQ空间使用
		oks.setSiteUrl("http://m.moregolden.com:36356/scorePage.html?moduleType=0&userType=0&time="
				+ Time
				+ "&mark="
				+ Score
				+ "&num="
				+ SPUtils.getString(this, ConfigConstant.USERNAME)
				+ "&exam_type=1");

		// 启动分享GUI
		oks.show(this);

	}
	public void showToast(String toast) {
		if (mediaPlayer != null) {
			mediaPlayer.stop();
			mediaPlayer.release();
			mediaPlayer = null;
			System.gc();
			// mediaPlayer = new MediaPlayer();
		}

		String uri=toast;
		
		if (mediaPlayer == null) {
			// SoundPool sp = new
			// SoundPool(10,AudioManager.STREAM_SYSTEM,0);
			// sp.load(path, priority);
			mediaPlayer = MediaPlayer.create(NewTestThirdActivity.this, Uri.parse(uri));
		}
		try {
//			mediaPlayer.reset();
//			mediaPlayer.setDataSource(uri);
//			mediaPlayer.prepare();
			mediaPlayer.start();

			mediaPlayer.setOnCompletionListener(new OnCompletionListener() {

				@Override
				public void onCompletion(MediaPlayer mp) {
					// TODO Auto-generated method stub
					Log.e("yubo", "uri===setOnCompletionListener");
					mediaPlayer.stop();
					mediaPlayer.release();
					mediaPlayer = null;
					System.gc();
				}
			});
			// mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
			//
			// @Override
			// public void onPrepared(MediaPlayer mp) {
			// // TODO Auto-generated method stub
			// mediaPlayer.start();
			//
			// }
			// });

		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalStateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
	
	   private BaseAnimatorSet bas_in;
			private BaseAnimatorSet bas_out;
			private String lESSON_NAME;

			public void setBasIn(BaseAnimatorSet bas_in) {
				this.bas_in = bas_in;
			}

			public void setBasOut(BaseAnimatorSet bas_out) {
				this.bas_out = bas_out;
			}

			private void NormalDialogCustomAttr() {
				final NormalDialog dialog = new NormalDialog(this);
				dialog.content("是否提交该考试成绩？").btnText("取消", "确认")//
						.style(NormalDialog.STYLE_TWO)//
						.titleTextSize(23)//
						.showAnim(bas_in)//
						.dismissAnim(bas_out)//
						.show();
				dialog.setCanceledOnTouchOutside(false);
				dialog.setOnBtnLeftClickL(new OnBtnLeftClickL() {

					@Override
					public void onBtnLeftClick() {
						
						finish();
						

					}
				});
				dialog.setOnBtnRightClickL(new OnBtnRightClickL() {

					@Override
					public void onBtnRightClick() {
						
						
						String c = SPUtil.getString(NewTestThirdActivity.this, "account", "");
						if(TextUtils.isEmpty(c)){
							dialog.dismiss();
							Intent intent = new Intent(NewTestThirdActivity.this,
									LoginActivity.class);
							startActivity(intent);
							finish();
						}else{
						
						Gson gson=new Gson();
						 String json = gson.toJson(timelist);
						Intent intent=new Intent(NewTestThirdActivity.this, ScoreSubmitActivity.class);
						intent.putExtra("Score", score);
						intent.putExtra("totalTime", totalTime);
						intent.putExtra("Uploadjson", json);
						intent.putExtra("lESSON_ID", lESSON_ID);
						intent.putExtra("LESSON_NAME", lESSON_NAME);
						intent.putExtra("exam_type", "1");
						
						startActivity(intent);
						dialog.dismiss();
						finish();
						}
					}
				});
			}
			
			Callback callbackcollect=new Callback() {
				

				@Override
				public void onFailure(Request arg0, IOException arg1) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void onResponse(Response arg0) throws IOException {
					// TODO Auto-generated method stub
					
				}
			};
			
			private String rid;
			private RequestCallBack<String> callBackTime = new RequestCallBack<String>() {
				

				@Override
				public void onSuccess(ResponseInfo<String> responseInfo) {
					// TODO Auto-generated method stub
					String json = responseInfo.result;
					// 使用Gson把json解析成对象
					// 1 得到gson对象

					// Log.i("testtime","wordfuxiresum"+ json.toString());
					 Log.i("testtime","newtestcallBackTime"+ json.toString());
					 
					Gson gson = new Gson();
					timeresq fromJson = gson.fromJson(json, timeresq.class);
					rid = fromJson.rid;

					Log.e("test", "rid===" + rid);
				}

				@Override
				public void onFailure(HttpException error, String msg) {
					// TODO Auto-generated method stub
					rid = "";
				}
			};
			
			private RequestCallBack<String> callBackTimefinish = new RequestCallBack<String>() {

				@Override
				public void onSuccess(ResponseInfo<String> responseInfo) {
					// TODO Auto-generated method stub
					String json = responseInfo.result;
					// 使用Gson把json解析成对象
					// 1 得到gson对象

					 Log.i("testtime","newtestcallBackTimefinish"+ json.toString());
				}

				@Override
				public void onFailure(HttpException error, String msg) {

				}
			};
			
}
